﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ninject;

namespace HobSoft.SoccerBet2014.Server
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Kernel = new StandardKernel(
                          new RepositoryIocModule()
                        , new ApplicationIocModule());
            Kernel.Settings.InjectNonPublic = true;

            var logerAppender = Kernel.Get<Log.ApplicationCacheLogAppender>();
            log4net.Config.BasicConfigurator.Configure(logerAppender);
            var logRepository = log4net.LogManager.GetRepository() as log4net.Repository.Hierarchy.Hierarchy;
            logRepository.Root.AddAppender(logerAppender);
            logRepository.Root.Level = log4net.Core.Level.All;
            logRepository.Configured = true;
            logRepository.Name = "ApplicationCacheLog";
            logRepository.RaiseConfigurationChanged(EventArgs.Empty);
            Application.Run(Kernel.Get<MainForm>());
        }

        public static IKernel Kernel
        {
            get;
            private set;
        }
    }
}
